<template>
    <div>
        <van-dialog
            v-model="show"

            :before-close="beforeClose">
            <van-field
                v-model="username"
                label="用户名"
                placeholder="请输入用户名"/>
            <van-field
                v-model="password"
                type="password"
                label="密码"
                placeholder="请输入密码"/>
        </van-dialog>
    </div>
</template>

<script>
    export default {
        model: {
            prop: "show",
            event: "change"
        },
        props: {
            show: {
                type: Boolean,
                default: false
            },
        },

        data() {
            return {
                username: '',
                password: ''
            };
        },

        methods: {
            beforeClose(action, done) {
                if (action === 'confirm') {
                    setTimeout(done, 1000);
                } else {
                    done();
                }
                this.close()
            },
            //关闭
            close() {
                this.$emit("update:show", false);
                this.$emit("change", false);
            },
        }
    }
</script>

<style scoped>

</style>